home *** CD-ROM | disk | FTP | other *** search
/ Tech Arsenal 1 / Tech Arsenal (Arsenal Computer).ISO / tek-04 / wtjmarch.zip / DEBUGWIN.ZIP / DWTFDD.PAS < prev   
Pascal/Delphi Source File  |  1992-01-08  |  1KB  |  60 lines

  1. LISTING 4: DWTFDD.PAS
  2. This unit uses Turbo Pascal's text file device driver feature to make debugging more elegant. You C guys are on your own.
  3.  
  4. {$S-,R-}
  5.  
  6. unit dwTFDD;
  7.  
  8. interface
  9.  
  10. uses
  11.   dwCall, WinDos;
  12.  
  13.   procedure AssignDW(var F : Text);
  14.  
  15. implementation
  16.  
  17.   function dwOutput(var F : TTextRec) : Integer; far;
  18.     {-Text file device driver output function}
  19.   begin
  20.     if F.BufPos <> 0 then begin
  21.       dwWriteBuf(PChar(F.BufPtr), F.BufPos);
  22.       F.BufPos := 0;
  23.     end;
  24.     dwOutput := 0;
  25.   end;
  26.  
  27.   function dwClose(var F : TTextRec) : Integer; far;
  28.     {-Text file device driver close function}
  29.   begin
  30.     dwClose := 0;
  31.   end;
  32.  
  33.   function dwOpen(var F : TTextRec) : Integer; far;
  34.     {-Text file device driver open function}
  35.   begin
  36.     F.Mode := fmOutput;
  37.     F.InOutFunc := @dwOutput;
  38.     F.FlushFunc := @dwOutput;
  39.     F.CloseFunc := @dwClose;
  40.     dwOpen := 0;
  41.   end;
  42.  
  43.   procedure AssignDW(var F : Text);
  44.   begin
  45.     with TTextRec(F) do begin
  46.       Handle := $FFFF;
  47.       Mode := fmClosed;
  48.       BufSize := SizeOf(Buffer);
  49.       BufPtr := @Buffer;
  50.       OpenFunc := @dwOpen;
  51.       Name[0] := #0;
  52.     end;
  53.   end;
  54.  
  55. begin
  56.   {set up Output to write to DebugWin's window}
  57.   AssignDW(Output);
  58.   Rewrite(Output);
  59. end.
  60.